package com.example.administrator.foodrowfresh.configs.classifyconfing.classifyentity;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import org.json.JSONException;
import org.json.JSONObject;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by lqr on 2016/5/2.
 */
public class MyVegetableEntity {

    /**
     * success : 1
     * data : {"list":[{"ParentCategoryId":1,"MetaKeywords":"新鲜蔬菜","SmallCategories":[{"SCategoryId":33,"SCategoryName":"叶菜类","PictureUrl":"http://images4sh-app.34580.com/images/CategoryImages/SH_Image_12464_png_160.png"},{"SCategoryId":34,"SCategoryName":"根茎类","PictureUrl":"http://images4sh-app.34580.com/images/CategoryImages/SH_Image_12470_png_160.png"},{"SCategoryId":35,"SCategoryName":"茄果类","PictureUrl":"http://images4sh-app.34580.com/images/CategoryImages/SH_Image_12466_png_160.png"},{"SCategoryId":36,"SCategoryName":"鲜菌菇类","PictureUrl":"http://images4sh-app.34580.com/images/CategoryImages/SH_Image_12469_png_160.png"},{"SCategoryId":37,"SCategoryName":"葱蒜调味类","PictureUrl":"http://images4sh-app.34580.com/images/CategoryImages/SH_Image_12467_png_160.png"},{"SCategoryId":97,"SCategoryName":"精品蔬菜","PictureUrl":"http://images4sh-app.34580.com/images/CategoryImages/SH_Image_12462_png_160.png"}]},{"ParentCategoryId":1,"MetaKeywords":"加工蔬菜","SmallCategories":[{"SCategoryId":107,"SCategoryName":"方便净菜","PictureUrl":"http://images4sh-app.34580.com/images/CategoryImages/SH_Image_12463_png_160.png"},{"SCategoryId":119,"SCategoryName":"冷冻蔬果","PictureUrl":"http://images4sh-app.34580.com/images/CategoryImages/SH_Image_12472_png_160.png"}]},{"ParentCategoryId":1,"MetaKeywords":"豆制品","SmallCategories":[{"SCategoryId":14,"SCategoryName":"豆腐","PictureUrl":"http://images4sh-app.34580.com/images/CategoryImages/SH_Image_12468_png_160.png"},{"SCategoryId":144,"SCategoryName":"半干豆制品","PictureUrl":"http://images4sh-app.34580.com/images/CategoryImages/SH_Image_19500_png_160.png"},{"SCategoryId":145,"SCategoryName":"面筋制品","PictureUrl":"http://images4sh-app.34580.com/images/CategoryImages/SH_Image_19493_png_160.png"},{"SCategoryId":146,"SCategoryName":"即食豆制品","PictureUrl":"http://images4sh-app.34580.com/images/CategoryImages/SH_Image_19494_png_160.png"},{"SCategoryId":147,"SCategoryName":"豆奶类","PictureUrl":"http://images4sh-app.34580.com/images/CategoryImages/SH_Image_19495_png_160.png"},{"SCategoryId":148,"SCategoryName":"真粉制品","PictureUrl":"http://images4sh-app.34580.com/images/CategoryImages/SH_Image_19497_png_160.png"},{"SCategoryId":149,"SCategoryName":"豆制干货类","PictureUrl":"http://images4sh-app.34580.com/images/CategoryImages/SH_Image_19496_png_160.png"}]},{"ParentCategoryId":1,"MetaKeywords":"有机蔬菜","SmallCategories":[{"SCategoryId":103,"SCategoryName":"有机蔬菜","PictureUrl":"http://images4sh-app.34580.com/images/CategoryImages/SH_Image_12471_png_160.png"}]}]}
     */

    private int success;
    private DataBean data;

    public static MyVegetableEntity objectFromData(String str) {

        return new Gson().fromJson(str, MyVegetableEntity.class);
    }

    public static MyVegetableEntity objectFromData(String str, String key) {

        try {
            JSONObject jsonObject = new JSONObject(str);

            return new Gson().fromJson(jsonObject.getString(str), MyVegetableEntity.class);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return null;
    }

    public static List<MyVegetableEntity> arrayMyVegetableEntityFromData(String str) {

        Type listType = new TypeToken<ArrayList<MyVegetableEntity>>() {
        }.getType();

        return new Gson().fromJson(str, listType);
    }

    public static List<MyVegetableEntity> arrayMyVegetableEntityFromData(String str, String key) {

        try {
            JSONObject jsonObject = new JSONObject(str);
            Type listType = new TypeToken<ArrayList<MyVegetableEntity>>() {
            }.getType();

            return new Gson().fromJson(jsonObject.getString(str), listType);

        } catch (JSONException e) {
            e.printStackTrace();
        }

        return new ArrayList();


    }

    public int getSuccess() {
        return success;
    }

    public void setSuccess(int success) {
        this.success = success;
    }

    public DataBean getData() {
        return data;
    }

    public void setData(DataBean data) {
        this.data = data;
    }

    public static class DataBean {
        /**
         * ParentCategoryId : 1
         * MetaKeywords : 新鲜蔬菜
         * SmallCategories : [{"SCategoryId":33,"SCategoryName":"叶菜类","PictureUrl":"http://images4sh-app.34580.com/images/CategoryImages/SH_Image_12464_png_160.png"},{"SCategoryId":34,"SCategoryName":"根茎类","PictureUrl":"http://images4sh-app.34580.com/images/CategoryImages/SH_Image_12470_png_160.png"},{"SCategoryId":35,"SCategoryName":"茄果类","PictureUrl":"http://images4sh-app.34580.com/images/CategoryImages/SH_Image_12466_png_160.png"},{"SCategoryId":36,"SCategoryName":"鲜菌菇类","PictureUrl":"http://images4sh-app.34580.com/images/CategoryImages/SH_Image_12469_png_160.png"},{"SCategoryId":37,"SCategoryName":"葱蒜调味类","PictureUrl":"http://images4sh-app.34580.com/images/CategoryImages/SH_Image_12467_png_160.png"},{"SCategoryId":97,"SCategoryName":"精品蔬菜","PictureUrl":"http://images4sh-app.34580.com/images/CategoryImages/SH_Image_12462_png_160.png"}]
         */

        private List<ListBean> list;

        public static DataBean objectFromData(String str) {

            return new Gson().fromJson(str, DataBean.class);
        }

        public static DataBean objectFromData(String str, String key) {

            try {
                JSONObject jsonObject = new JSONObject(str);

                return new Gson().fromJson(jsonObject.getString(str), DataBean.class);
            } catch (JSONException e) {
                e.printStackTrace();
            }

            return null;
        }

        public static List<DataBean> arrayDataBeanFromData(String str) {

            Type listType = new TypeToken<ArrayList<DataBean>>() {
            }.getType();

            return new Gson().fromJson(str, listType);
        }

        public static List<DataBean> arrayDataBeanFromData(String str, String key) {

            try {
                JSONObject jsonObject = new JSONObject(str);
                Type listType = new TypeToken<ArrayList<DataBean>>() {
                }.getType();

                return new Gson().fromJson(jsonObject.getString(str), listType);

            } catch (JSONException e) {
                e.printStackTrace();
            }

            return new ArrayList();


        }

        public List<ListBean> getList() {
            return list;
        }

        public void setList(List<ListBean> list) {
            this.list = list;
        }

        public static class ListBean {
            private int ParentCategoryId;
            private String MetaKeywords;
            /**
             * SCategoryId : 33
             * SCategoryName : 叶菜类
             * PictureUrl : http://images4sh-app.34580.com/images/CategoryImages/SH_Image_12464_png_160.png
             */

            private List<SmallCategoriesBean> SmallCategories;

            public static ListBean objectFromData(String str) {

                return new Gson().fromJson(str, ListBean.class);
            }

            public static ListBean objectFromData(String str, String key) {

                try {
                    JSONObject jsonObject = new JSONObject(str);

                    return new Gson().fromJson(jsonObject.getString(str), ListBean.class);
                } catch (JSONException e) {
                    e.printStackTrace();
                }

                return null;
            }

            public static List<ListBean> arrayListBeanFromData(String str) {

                Type listType = new TypeToken<ArrayList<ListBean>>() {
                }.getType();

                return new Gson().fromJson(str, listType);
            }

            public static List<ListBean> arrayListBeanFromData(String str, String key) {

                try {
                    JSONObject jsonObject = new JSONObject(str);
                    Type listType = new TypeToken<ArrayList<ListBean>>() {
                    }.getType();

                    return new Gson().fromJson(jsonObject.getString(str), listType);

                } catch (JSONException e) {
                    e.printStackTrace();
                }

                return new ArrayList();


            }

            public int getParentCategoryId() {
                return ParentCategoryId;
            }

            public void setParentCategoryId(int ParentCategoryId) {
                this.ParentCategoryId = ParentCategoryId;
            }

            public String getMetaKeywords() {
                return MetaKeywords;
            }

            public void setMetaKeywords(String MetaKeywords) {
                this.MetaKeywords = MetaKeywords;
            }

            public List<SmallCategoriesBean> getSmallCategories() {
                return SmallCategories;
            }

            public void setSmallCategories(List<SmallCategoriesBean> SmallCategories) {
                this.SmallCategories = SmallCategories;
            }

            public static class SmallCategoriesBean {
                private int SCategoryId;
                private String SCategoryName;
                private String PictureUrl;

                public static SmallCategoriesBean objectFromData(String str) {

                    return new Gson().fromJson(str, SmallCategoriesBean.class);
                }

                public static SmallCategoriesBean objectFromData(String str, String key) {

                    try {
                        JSONObject jsonObject = new JSONObject(str);

                        return new Gson().fromJson(jsonObject.getString(str), SmallCategoriesBean.class);
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }

                    return null;
                }

                public static List<SmallCategoriesBean> arraySmallCategoriesBeanFromData(String str) {

                    Type listType = new TypeToken<ArrayList<SmallCategoriesBean>>() {
                    }.getType();

                    return new Gson().fromJson(str, listType);
                }

                public static List<SmallCategoriesBean> arraySmallCategoriesBeanFromData(String str, String key) {

                    try {
                        JSONObject jsonObject = new JSONObject(str);
                        Type listType = new TypeToken<ArrayList<SmallCategoriesBean>>() {
                        }.getType();

                        return new Gson().fromJson(jsonObject.getString(str), listType);

                    } catch (JSONException e) {
                        e.printStackTrace();
                    }

                    return new ArrayList();


                }

                public int getSCategoryId() {
                    return SCategoryId;
                }

                public void setSCategoryId(int SCategoryId) {
                    this.SCategoryId = SCategoryId;
                }

                public String getSCategoryName() {
                    return SCategoryName;
                }

                public void setSCategoryName(String SCategoryName) {
                    this.SCategoryName = SCategoryName;
                }

                public String getPictureUrl() {
                    return PictureUrl;
                }

                public void setPictureUrl(String PictureUrl) {
                    this.PictureUrl = PictureUrl;
                }
            }
        }
    }
}
